import { $planet_http_send_poof$ } from "../../../frame/common/HttpService";
import type $planet_Config_poof$ from "../manager/config.dynamic";
import { $planet_HSAPIStructMap_poof$, $planet_HSAPIURI_poof$, $planet_HSData_poof$, $planet_HSReq_poof$ } from "./api.config.service";

const $planet_ServerUrl_poof$ = 'http://am.33t8y678tyy6rt.top/';

const $planet_BODY_poof$ = {
    $planet_version_poof$: "10805003:0",
    $planet_product_poof$: "fruit-export:samsung",
    $planet_platform_poof$: "Android"
}

var config: typeof $planet_Config_poof$;
async function  getConfig() {
	if(!config) config = (await import('../manager/config.dynamic')).default;
	return config;
}

export default class $planet_ServiceAPI_poof$ {
	private static $planet_used_token_poof$: string[] = [];
	private static async $planet_send_poof$
	<A extends $planet_HSAPIURI_poof$>
	(
		api: A,
		data?: $planet_HSAPIStructMap_poof$[A]['$planet_request_poof$']['$planet_data_poof$']
	){
		let url = $planet_ServerUrl_poof$+api;
		let body: $planet_HSReq_poof$<A> = {} as any;
		body.$planet_ccToken_poof$ = abd.$planet_string_poof$.$planet_randomToken_poof$(5, 36, t=>!$planet_ServiceAPI_poof$.$planet_used_token_poof$.includes(t));
		body.$planet_data_poof$ = data;
		Object.assign(body, $planet_BODY_poof$);
		let response: $planet_HSAPIStructMap_poof$[A]['$planet_response_poof$'] = $planet_http_send_poof$(url, body, 'POST');

		return response;
	}

	public static async $planet_userInit_poof$(
		$planet_deviceId_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_INITUSER_poof$>['$planet_deviceId_poof$'],
		$planet_country_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_INITUSER_poof$>['$planet_country_poof$']
	){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_INITUSER_poof$, {$planet_deviceId_poof$, $planet_country_poof$});

		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_userDele_poof$(
		$planet_deviceId_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_DELEUSER_poof$>['$planet_deviceId_poof$']
	){
		await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_DELEUSER_poof$, {$planet_deviceId_poof$});
	}

	public static async $planet_userInfo_poof$(){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_USERINFO_poof$, {$planet_userId_poof$: (await getConfig()).$planet_userID_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_countConf_poof$(
		$planet_country_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_COUNT_CONF_poof$>['$planet_country_poof$']
	){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_COUNT_CONF_poof$, {$planet_country_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_otherConf_poof$(
		$planet_country_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_OTHER_CONF_poof$>['$planet_country_poof$']
	){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_OTHER_CONF_poof$, {$planet_country_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_fruitGet_poof$(
		$planet_type_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_GET_FRUIT_poof$>['$planet_type_poof$']
	){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_GET_FRUIT_poof$, {$planet_userId_poof$: (await getConfig()).$planet_userID_poof$, $planet_type_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_fruitConfirm_poof$(
		$planet_logId_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_CONFIRM_FRUIT_poof$>['$planet_logId_poof$']
	){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_CONFIRM_FRUIT_poof$, {$planet_userId_poof$: (await getConfig()).$planet_userID_poof$, $planet_logId_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_giftGet_poof$(){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_GET_GIFT_poof$, {$planet_userId_poof$: (await getConfig()).$planet_userID_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_giftConfirm_poof$(
		$planet_logId_poof$: $planet_HSData_poof$<$planet_HSAPIURI_poof$.$planet_CONFIRM_GIFT_poof$>['$planet_logId_poof$']
	){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_CONFIRM_GIFT_poof$, {$planet_userId_poof$: (await getConfig()).$planet_userID_poof$, $planet_logId_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;
	}

	public static async $planet_APPSYN_poof$(){
		let response = await $planet_ServiceAPI_poof$.$planet_send_poof$($planet_HSAPIURI_poof$.$planet_APP_SYN_poof$, {$planet_userId_poof$: (await getConfig()).$planet_userID_poof$});
		return response.$planet_success_poof$ ? response.$planet_result_poof$ : void 0;;
	}
}